/**
 * @param {number[]} candidates
 * @param {number} target
 * @return {number[][]}
 */
 var combinationSum = function(candidates, target) {
    let res=[];
    let group=[];
    function dfs(i=0,sum=0){
        if(sum>target){
            return;
        }
        if(sum==target){
            res.push([...group]);
            return;
        }
        for (;i<candidates.length;i++){
            group.push(candidates[i]);
            dfs(i,sum+candidates[i]);
            group.pop();
        }
    }
    dfs();
    return res;
};